package com.shelpe.services.sustainer.step;

import java.util.Date;

import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.beans.factory.annotation.Autowired;

import com.shelpe.services.sustainer.entity.jpa.InprogressJob;
import com.shelpe.services.sustainer.repository.jpa.InprogressJobRepository;

public class InprogressRecordStep extends AbstractStep {

	@Autowired
	private InprogressJobRepository inprogressJobRepository;
	
	@Override
	protected void doExecute(StepExecution stepExecution) throws Exception {
		InprogressJob job = new InprogressJob();
		job.setJobID(stepExecution.getJobExecution().getJobId() + "");
		job.setJobName(stepExecution.getJobExecution().getJobInstance().getJobName());
		job.setCreatedTime(new Date());
		job.setModifiedTime(new Date());
		
		this.inprogressJobRepository.save(job);
	}

}
